package mio.util;

import java.util.ArrayList;
import java.util.Hashtable;

import mio.model.*;
import mio.services.IMIORepository;

public class MIORepository implements IMIORepository {

	private Hashtable<String, Line> lines;
	private Hashtable<String, Stop> stops;
	private ArrayList<CreditPoint> puntosRecarga;
	private ArrayList<MobileUnit> unidadesMoviles;

	public MIORepository() {
		this.lines = new Hashtable<String, Line>();
		this.stops = new Hashtable<String, Stop>();
		System.out.println("creando paradas");
		createStops();
		System.out.println("creando lineas");
		createLines();
		System.out.println("creando puntos de recarga");
		createCreditPoints();
		System.out.println("creando unidades moviles");
		createMobileUnits();
	}

	private void createMobileUnits() {		
		unidadesMoviles = new ArrayList<MobileUnit>();
		unidadesMoviles.add(new MobileUnit(0, "MC22000", "Padron", 3.414374, -76.54751));
		unidadesMoviles.add(new MobileUnit(1, "MC22001", "Padron", 3.374048, -76.54014));
		unidadesMoviles.add(new MobileUnit(2, "MC22002", "Padron", 3.425156, -76.54484));
		unidadesMoviles.add(new MobileUnit(3, "MC22003", "Padron", 3.425156, -76.54484));
		unidadesMoviles.add(new MobileUnit(4, "MC22004", "Padron", 3.437975, -76.53896));		
	}

	private void createCreditPoints() {
		puntosRecarga = new ArrayList<CreditPoint>();
		puntosRecarga.add(new CreditPoint(0, "Cosmocentro1", "Pasillo 2",
				3.414374, -76.54751));
		puntosRecarga.add(new CreditPoint(1, "Unicentro", "Pasillo 1",
				3.374048, -76.54014));
		puntosRecarga.add(new CreditPoint(2, "ExitoSanFernando", "Pasillo 4",
				3.425156, -76.54484));
		puntosRecarga.add(new CreditPoint(3, "LomaDeLaCruz", "Local 40",
				3.437975, -76.53896));
		puntosRecarga.add(new CreditPoint(4, "CentroComercialGalerias",
				"pasillo 6", 3.444273, -76.500749));
	}

	private void createLines() {
		ArrayList<Stop> stopsE31 = new ArrayList<Stop>();
		stopsE31.add(stops.get("chiminangos"));
		stopsE31.add(stops.get("torredecali"));
		stopsE31.add(stops.get("sanbosco"));
		stopsE31.add(stops.get("estadio"));
		stopsE31.add(stops.get("unidaddeportiva"));
		stopsE31.add(stops.get("universidades"));
		Line e31 = new Line(1, "E31", "Chiminangos - Universidades", stopsE31);

		ArrayList<Stop> stopsE21 = new ArrayList<Stop>();
		stopsE21.add(stops.get("menga"));
		stopsE21.add(stops.get("torredecali"));
		stopsE21.add(stops.get("sanbosco"));
		stopsE21.add(stops.get("tequendama"));
		stopsE21.add(stops.get("unidaddeportiva"));
		stopsE21.add(stops.get("estadio"));
		stopsE21.add(stops.get("melendez"));
		stopsE21.add(stops.get("univalle"));
		stopsE21.add(stops.get("universidades"));
		Line e21 = new Line(2, "E21", "Terminal Menga - Universidades",
				stopsE21);

		ArrayList<Stop> stopsP40 = new ArrayList<Stop>();
		stopsP40.add(stops.get("universidades"));
		stopsP40.add(stops.get("univalle"));
		stopsP40.add(stops.get("sanpascual"));
		stopsP40.add(stops.get("ermita"));
		stopsP40.add(stops.get("estadio"));
		stopsP40.add(stops.get("univalle"));
		stopsP40.add(stops.get("universidades"));
		Line p40 = new Line(3, "P40", "Universidades - Ermita - Universidades",
				stopsP40);

		lines.put("e31", e31);
		lines.put("e21", e21);
		lines.put("p40", p40);
	}

	private void createStops() {
		Stop chiminangos = new Stop(1, "Chiminangos",
				"Colombia # 62-1 a 62-85, Cali, Valle del Cauca, Colombia",
				3.48138833, -76.49837833);
		Stop torreDeCali = new Stop(
				2,
				"Torre de Cali",
				"Avenida De Las Américas # 1 a 55, Cali, Valle del Cauca, Colombia",
				3.45674833, -76.530325);
		Stop sanBosco = new Stop(3, "San Bosco",
				"Carrera 15 # 9B-1 a 9B-99, Cali, Valle del Cauca, Colombia",
				3.44234, -76.532455);
		Stop estadio = new Stop(4, "Estadio",
				"Calle 5 # 34-1 a 34-99, Cali, Valle del Cauca, Colombia",
				3.43189833, -76.54316167);
		Stop unidadDeportiva = new Stop(5, "Unidad Deportiva",
				"Calle 5 # 48-1 a 48-99, Cali, Valle del Cauca, Colombia",
				3.41458667, -76.54823833);
		Stop universidades = new Stop(6, "Universidades",
				"Carrera 100 # 16-21 a 16-99, Cali, Valle del Cauca, Colombia",
				3.36682167, -76.52896);

		Stop menga = new Stop(
				7,
				"Terminal Menga",
				"Autooriental # 2C-2 a 2C-100, Cali, Valle del Cauca, Colombia",
				3.48919806, -76.50918028);
		Stop tequendama = new Stop(8, "Tequendama",
				"Calle 5 # 40-1 a 40-99, Cali, Valle del Cauca, Colombia",
				3.42356667, -76.54703);
		Stop melendez = new Stop(9, "Melendez",
				"Calle 5 # 2 a 26, Cali, Valle del Cauca, Colombia", 3.37701,
				-76.54277833);

		Stop univalle = new Stop(10, "Univalle",
				"Carrera 100 # 44 a 66, Cali, Valle del Cauca, Colombia",
				3.37068667, -76.536625);
		Stop sanPascual = new Stop(11, "San Pascual",
				"Carrera 15 # 13A-1 a 13A-99, Cali, Valle del Cauca, Colombia",
				3.44265167, -76.52769667);
		Stop ermita = new Stop(12, "La Ermita",
				"Paso Ancho # 3-14 a 3-122, Cali, Valle del Cauca, Colombia",
				3.45362917, -76.53174389);

		stops.put("chiminangos", chiminangos);
		stops.put("torredecali", torreDeCali);
		stops.put("sanbosco", sanBosco);
		stops.put("estadio", estadio);
		stops.put("unidaddeportiva", unidadDeportiva);
		stops.put("universidades", universidades);

		stops.put("menga", menga);
		stops.put("tequendama", tequendama);
		stops.put("melendez", melendez);

		stops.put("univalle", univalle);
		stops.put("sanpascual", sanPascual);
		stops.put("ermita", ermita);
	}

	@Override
	public Hashtable<String, Stop> getStops() {
		return stops;
	}

	@Override
	public Hashtable<String, Line> getLines() {
		return lines;
	}

	@Override
	public ArrayList<CreditPoint> getCreditPoints() {
		return puntosRecarga;
	}

	@Override
	public ArrayList<MobileUnit> getMobileUnits() {
		return unidadesMoviles;
	}

}
